/**
 * @Author: code.rookie
 * @ClassName: DegreeofanArray
 * @Date: 2021/10/13 4:14 下午
 * @Version: 1
 * @Description 697. 数组的度
 */
public class DegreeofanArray {
    public static void main(String[] args) {
        int[] height = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        int result = 0;
        int i = 0, j = height.length - 1;
        while (i < j) {
            result = Math.max(result, Math.min(height[i], height[j]) * (j - i));
            if (height[i] > height[j]) {
                j--;
            } else {
                i++;
            }
        }
        System.out.println(result);
    }
}
